Introduction to the HMM using the example of CAB crisis states
Here, we investigated
- State composition at the group level
- State dynamics at the group level
- Most likely state sequence over time
Same topics in the practical, using data on mood.
May 29, 2025
Introduction to the HMM using the example of CAB crisis states
Here, we investigated
Same topics in the practical, using data on mood.
Expand the HMM to the multilevel framework
And
Multilevel framework
Individual specific models of dynamics
Analyzing data from multiple individuals
Including a multilevel framework for the HMM, enables simultaneous estimation:
For the variable & state dependent emission Normal means:
For the state dynamics:
Multinomial logistic regression to estimate transition probabilities \(\gamma_{nij}\)
\(\gamma_{nij} = \frac{\text{exp}(\alpha_{nij})}{1 + \sum_{{j} = 2}^m \text{exp}(\alpha_{ni{j}})} \quad\) where \(\quad \alpha_{nij} = \bar{\alpha}_{ij} + \epsilon_{\left[\alpha\right]nij}\)
Adopt a Bayesian approach
Individual specific means / intercepts are sampled from a Normal distribution
Combining:
26 patients, 60 observations per patient per CAB factor
emiss_subj <- obtain_emiss(CAB_mHMM_4st, level = "individual")
emiss_subj <- obtain_emiss(CAB_mHMM_4st, level = "individual")
Important to check conceptual state equivalence over individuals!
gamma_subj <- obtain_gamma(CAB_mHMM_4st, level = "individual")
Pairing fine grained ESM data with multilevel HMM, we
Model selection
A pragmatic step by step approach
Number of states is a fixed ‘parameter’ in the model, to be determined by the researcher.
Note: within Bayesian framework, can make the number of states a model parameter using a reversible jump MCMC algorithm, but within the context of a multilevel model, computationally too intense.
Pohle & Langrock (2017) suggested a pragmatic step-by-step approach:
| Mean Rhat (% \(>\) 1.2) | 2-state model | 3-state model | 4-state model | 5-state model |
|---|---|---|---|---|
| Transition parameters | 1.02 (0.0%) | 1.01 (0.0%) | 1.02 (6.25%) | 1.04 (16.0%) |
| Composition parameters | 1.01 (0.0%) | 1.01 (0.0%) | 1.03 (0.0%) | 1.04 (4.0%) |
Model checking
Label switching, Convergence, PPCs and pseudo residuals
Check: rule out results from a local (instead of global) maximum.
How to check convergence:
\(\rightarrow\) multiple MCMC chains.
| Mean Rhat (% \(>\) 1.2) | 4-state model |
|---|---|
| Transition parameters | 1.02 (6.25%) |
| Composition parameters | 1.03 (0.0%) |
In mixture models, such as HMMs, the orderning of the hidden states do not affect the fit (i.e., likelihood) of the model.
Consequence:
In multilevel HMMs:
How to check:
Occurrence depends on:
Occurrence depends on:
Severe label switching:
Minor label switching:
Check: does model recover the data correctly on an array of characteristics, aids in revealing model missspecification.
PPCs can be used to assess model fit at both the individual and group-level.
Check: is the model a good fit to the data of each individual?
Pseudo residuals at each time point: observed - predicted outcome.
Use for typical residual checking: e.g., normality, heteroscedasticity, lack of trend over time, and autocorrelation.
Let’s continue with our own multilevel HMM in the lab!
All materials are available on: